<template>
	<view class="content">

		<button v-if="isButtom" open-type="contact" :session-from="userInfo.nickname">
			<view class="yt-list-cell" :class="border" hover-class="cell-hover" :hover-stay-time="50">
			<text v-if="icon" class="cell-icon" :style="[{
					color: iconColor,
				}]" :class="icon"></text>
			<view class="cell-image" v-if="image">
				<image :src="'/static/images/' + image + '.png'"></image>
			</view>
			<text class="cell-tit clamp">{{title}}</text>
			<text v-if="tips" class="cell-tip">{{tips}}</text>
			<text class="cell-more" :class="typeList[navigateType]"></text>
			</view>
		</button>

		<view v-else class="yt-list-cell" :class="border" @click="eventClick" hover-class="cell-hover" :hover-stay-time="50">
			<text v-if="icon" class="cell-icon" :style="[{
					color: iconColor,
				}]" :class="icon"></text>
			<view class="cell-image" v-if="image">
				<image :src="'/static/images/' + image + '.png'"></image>
			</view>
			<text class="cell-tit clamp">{{title}}</text>
			<text v-if="tips" class="cell-tip">{{tips}}</text>
			<text v-if="teamcount" class="cell-tip-team">{{teamcount}}位团队成员</text>
			<text v-if="leftIcon" class="cell-more" :class="typeList[navigateType]"></text>
		</view>

	</view>
</template>

<script>
	import {
		mapState,
		mapMutations
	} from 'vuex';
	export default {
		name: "npListCell",
		computed: {
			...mapState(['userInfo'])
		},
		data() {
			return {
				typeList: {
					left: 'icon-zuo',
					right: 'icon-you',
					up: 'icon-shang',
					down: 'icon-xia'
				},
			}
		},
		props: {
			icon: {
				type: String,
				default: ''
			},
			image: {
				type: String,
				default: ''
			},
			isButtom: {
				type: Boolean,
				default: false
			},
			title: {
				type: String,
				default: '标题'
			},
			tips: {
				type: String,
				default: ''
			},
			teamcount: {
				type: Number,
				default: 0
			},
			navigateType: {
				type: String,
				default: 'right'
			},
			border: {
				type: String,
				default: 'b-b'
			},
			hoverClass: {
				type: String,
				default: 'cell-hover'
			},
			iconColor: {
				type: String,
				default: '#333'
			},
			leftIcon: {
				type: Boolean,
				default: true
			}
		},
		methods: {
			eventClick() {
				this.$emit('eventClick');
			}
		},
	}
</script>

<style lang='scss'>
	button {
		text-align: left;
		border-radius: 0;
		background-color: #fff;
		line-height: 100upx;
		height: 100upx;
		padding: 0;
		margin: 0;
	}

	button::after {
		border: none;
	}

	.icon .yt-list-cell.b-b:after {
		left: 90upx;
	}

	.yt-list-cell {
		display: flex;
		align-items: baseline;
		padding: 20rpx 30rpx;
		line-height: 60rpx;
		position: relative;

		&.cell-hover {
			background: #fafafa;
		}

		&.b-b:after {
			left: 30upx;
		}

		.cell-icon {
			font-family: "nuopianfont";
			align-self: center;
			width: 56upx;
			max-height: 60upx;
			font-size: 38upx;
		}

		.cell-image {
			align-self: center;
			width: 56upx;
			height: 45upx;

			image {
				width: 45upx;
				height: 100%;
			}
		}

		.cell-more {
			font-family: "nuopianfont";
			align-self: center;
			font-size: 30upx;
			color: #606266;
			margin-left: $uni-spacing-row-sm;
		}

		.cell-tit {
			flex: 1;
			font-size: $uni-font-size-base;
			color: #303133;
			margin-right: 10upx;
		}

		.cell-tip {
			font-size: 24rpx;
			color: #909399;
		}

		.cell-tip-team {
			font-size: 24rpx;
			color: red;
		}
	}
</style>
